﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using DataAccessLayer;
using DataAccessLayer.DAL;
using Common;
namespace BestBuy.AdminViews
{
    public partial class Banner : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = UserDAL.GetUserByUsername(HttpContext.Current.User.Identity.Name);
            if (user == null || user.RoleID != (int)RoleType.Admin)
            {
                Response.Redirect("~/Account/Login.aspx");
            }

            if (!Page.IsPostBack)
            {
            }
        }
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            if (FileUploadControl.HasFile)
            {
                try
                {
                    string root = "~/FileUpload/";
                    string filename = Path.GetFileName(FileUploadControl.FileName);
                    FileUploadControl.SaveAs(Server.MapPath(root) + filename);
                    AdminInfoMessage.Show("Success upload banner.", UserControls.MessagePanel.MessageType.Success);
                 }
               catch (Exception ex)
                  {
                Label1.Text = "ERROR: " + ex.Message.ToString();
            }   
            }
            else
                {
                    Label1.Text = "You have not specified a file.";
                }
      }
        }
    }
